import {RestRiskCheckStatus} from '../model/RestRiskCheckStatus'
import {RestResult} from '../model/RestResult'
import {UIRiskType} from '../model/UIRiskType'
import {UIRiskFixType} from '../model/UIRiskFixType'
import {UIRiskLevel} from '../model/UIRiskLevel'
import {UIRiskReport} from '../model/UIRiskReport'
import {UIRiskCheckTarget} from '../model/UIRiskCheckTarget'
import {RestRiskCheckItemStatus} from '../model/RestRiskCheckItemStatus'
import {UIRiskCheck} from '../model/UIRiskCheck'
import {UIRiskCause} from '../model/UIRiskCause'
import {UIRiskCheckItem} from '../model/UIRiskCheckItem'
import {UIRiskCheckCriteria} from '../model/UIRiskCheckCriteria'
import {Collection} from '../model/Collection'
import {UIRiskCheckItemCriteria} from '../model/UIRiskCheckItemCriteria'
import { Injectable } from '@angular/core';
import { AuthHttp } from 'angular2-jwt'
import { Observable } from "rxjs/Observable";
import { Environment } from '../environments/environment'
import 'rxjs/add/operator/map';
import { RestResult } from '../common/model/rest-result'

@Injectable()
export class  CCRiskControllerService {
  constructor (
    private http: AuthHttp,
    private env: Environment
  ){ }
  riskCheckList(uiCriteria: UIRiskCheckCriteria): Observable<any /*TODO: specifiy type argument*/> {
    return this.http.post(this.env.urlPrefix + "/windbell/riskCheck/list" , uiCriteria).map((res)=>{
    	let restResult = res.json() as RestResult<any /*TODO: specifiy type argument*/>
    	return restResult.value
    })
  }
  getRiskCheckDetail(id: number): Observable<UIRiskCheck> {
    return this.http.get(this.env.urlPrefix + `/windbell/riskCheck/${id}` ).map((res)=>{
    	let restResult = res.json() as RestResult<UIRiskCheck>
    	return restResult.value
    })
  }
  riskCheckItemList(uiCriteria: UIRiskCheckItemCriteria): Observable<any /*TODO: specifiy type argument*/> {
    return this.http.post(this.env.urlPrefix + "/windbell/riskCheckItem/list" , uiCriteria).map((res)=>{
    	let restResult = res.json() as RestResult<any /*TODO: specifiy type argument*/>
    	return restResult.value
    })
  }
  getRiskCheckItemDetail(id: number): Observable<UIRiskCheckItem> {
    return this.http.get(this.env.urlPrefix + `/windbell/riskCheckItem/${id}` ).map((res)=>{
    	let restResult = res.json() as RestResult<UIRiskCheckItem>
    	return restResult.value
    })
  }
  createRiskReport(id: number,report: UIRiskReport): Observable<any /*TODO: specifiy type argument*/> {
    return this.http.post(this.env.urlPrefix + `/windbell/riskCheckItem/${id}/report` , report).map((res)=>{
    	let restResult = res.json() as RestResult<any /*TODO: specifiy type argument*/>
    	return restResult.value
    })
  }
  riskReportList(): Observable<any /*TODO: specifiy type argument*/> {
    return this.http.get(this.env.urlPrefix + "/windbell/riskReport/list" ).map((res)=>{
    	let restResult = res.json() as RestResult<any /*TODO: specifiy type argument*/>
    	return restResult.value
    })
  }
  riskReportDetail(id: number): Observable<any /*TODO: specifiy type argument*/> {
    return this.http.get(this.env.urlPrefix + `/windbell/riskCheckItem/${id}/report` ).map((res)=>{
    	let restResult = res.json() as RestResult<any /*TODO: specifiy type argument*/>
    	return restResult.value
    })
  }
  getRiskType(): Observable<UIRiskType[]> {
    return this.http.get(this.env.urlPrefix + "/windbell/riskType" ).map((res)=>{
    	let restResult = res.json() as RestResult<UIRiskType[]>
    	return restResult.value
    })
  }
  getRiskLevel(): Observable<UIRiskLevel[]> {
    return this.http.get(this.env.urlPrefix + "/windbell/riskLevel" ).map((res)=>{
    	let restResult = res.json() as RestResult<UIRiskLevel[]>
    	return restResult.value
    })
  }
  getRiskCause(): Observable<UIRiskCause[]> {
    return this.http.get(this.env.urlPrefix + "/windbell/riskCause" ).map((res)=>{
    	let restResult = res.json() as RestResult<UIRiskCause[]>
    	return restResult.value
    })
  }
  getRiskFixType(): Observable<UIRiskFixType[]> {
    return this.http.get(this.env.urlPrefix + "/windbell/riskFixType" ).map((res)=>{
    	let restResult = res.json() as RestResult<UIRiskFixType[]>
    	return restResult.value
    })
  }
  checkTargetList(): Observable<UIRiskCheckTarget[]> {
    return this.http.get(this.env.urlPrefix + "/windbell/checkTarget" ).map((res)=>{
    	let restResult = res.json() as RestResult<UIRiskCheckTarget[]>
    	return restResult.value
    })
  }
  riskCheckStatusList(): Observable<RestRiskCheckStatus[]> {
    return this.http.get(this.env.urlPrefix + "/windbell/riskCheckStatus" ).map((res)=>{
    	let restResult = res.json() as RestResult<RestRiskCheckStatus[]>
    	return restResult.value
    })
  }
  riskCheckItemStatusList(): Observable<RestRiskCheckItemStatus[]> {
    return this.http.get(this.env.urlPrefix + "/windbell/riskCheckItemStatus" ).map((res)=>{
    	let restResult = res.json() as RestResult<RestRiskCheckItemStatus[]>
    	return restResult.value
    })
  }
}
